package cn.ncu.service;

import cn.ncu.dao.UserDao;
import cn.ncu.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl implements UserService{

    @Autowired
    private UserDao userDao;


    /**
     * 用户注册
     */
    @Override
    public void register(User user) {
        userDao.saveUser(user);
    }


    /**
     * 用户邮箱登录
     * @param email
     * @param password
     * @return
     */
    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public User login(String email, String password) {
        return userDao.queryUser(email, password);
    }

    /**
     * 更新用户信息
     * @param user
     */
    @Override
    public void updateUser(User user) {
        userDao.updateUser(user);
    }
}
